package p2000;

import java.util.Scanner;

public class Main2033人见人爱A加B {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-- > 0) {
            int ah = scanner.nextInt();
            int am = scanner.nextInt();
            int as = scanner.nextInt();
            int bh = scanner.nextInt();
            int bm = scanner.nextInt();
            int bs = scanner.nextInt();

            int cm = 0;
            int ch = 0;
            int cs = as + bs;
            if (cs > 60) {
                cm++;
                cs = cs % 60;
            }

            cm = cm + am + bm;
            if (cm > 60) {
                ch++;
                cm = cm % 60;
            }

            ch = ch + ah + bh;

            System.out.println(ch + " " + cm + " " + cs);
        }
    }

}
